home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 1
/
Nebula One.iso
/
Mail
/
pine3.92
/
pine
/
osdep
/
execview
< prev
next >
Wrap
Text File
|
1995-10-25
|
2KB
|
76 lines
/* ----------------------------------------------------------------------
Execute the given mailcap command
Args: cmd -- the command to execute
image_file -- the file the data is in
needsterminal -- does this command want to take over the terminal?
----*/
void
exec_mailcap_cmd(cmd, image_file, needsterminal)
char *cmd;
char *image_file;
int needsterminal;
{
char *command = NULL,
*result_file = NULL,
*p;
char **r_file_h;
PIPE_S *syspipe;
int mode;
p = command = (char *)fs_get((32 + strlen(cmd) + (2*strlen(image_file)))
* sizeof(char));
if(!needsterminal) /* put in background if it doesn't need terminal */
*p++ = '(';
sprintf(p, "%s ; rm -f %s", cmd, image_file);
p += strlen(p);
if(!needsterminal){
*p++ = ')';
*p++ = ' ';
*p++ = '&';
}
*p++ = '\n';
*p = '\0';
dprint(9, (debugfile, "exec_mailcap_cmd: command=%s\n", command));
mode = PIPE_RESET;
if(needsterminal)
r_file_h = NULL;
else{
mode |= PIPE_WRITE | PIPE_STDERR;
result_file = temp_nam(NULL, "pine_cmd");
r_file_h = &result_file;
}
if(syspipe = open_system_pipe(command, r_file_h, NULL, mode)){
close_system_pipe(&syspipe);
if(needsterminal)
q_status_message(SM_ORDER, 0, 4, "VIEWER command completed");
else
display_output_file(result_file, "VIEWER", " command launched");
}
else
q_status_message1(SM_ORDER, 3, 4, "Cannot spawn command : %s", cmd);
fs_give((void **)&command);
if(result_file)
fs_give((void **)&result_file);
}
/* ----------------------------------------------------------------------
Execute the given mailcap test= cmd
Args: cmd -- command to execute
Returns exit status
----*/
int
exec_mailcap_test_cmd(cmd)
char *cmd;
{
return(system(cmd));
}